package com.binyw.opencv

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.binyw.opencv.image_process.ImageProcessPage
import com.example.base_model.weight.MyTopBar
import com.example.base_model.weight.RoundedRectButton

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            val navController = rememberNavController()
            Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                NavHost(navController = navController, startDestination = AppPage.Main.name) {
                    composable(AppPage.Main.name) { MainPage(navController) }
                    composable(AppPage.ImageProcess.name) { ImageProcessPage(navController) }
                }
            }
        }
    }
}

@Composable
fun MainPage(nav: NavHostController) {
    Column(modifier = Modifier.fillMaxSize()) {
        MyTopBar(title = stringResource(R.string.app_name), showAction = false)
        Column(
            modifier = Modifier.fillMaxSize(),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center
        ) {
            RoundedRectButton(stringResource(R.string.image_processing), {
                nav.navigate(AppPage.ImageProcess.name)
            })
        }
    }
}